using FishFillets.Model;
using FishFillets.Model.GameItems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using FishFillets.GameComponents.Helpers;

namespace FishFillets.GameComponents
{
    public class ItemComponent : BaseItemComponent
    {
        private readonly Item item;

        public ItemComponent(Game game, ContentManager contentManager, AssetHelper contentAltManager, Item item, string name)
            : base(game, contentManager, contentAltManager, name)
        {
            this.item = item;
        }

        protected override void LoadContent()
        {
            texture = contentAltManager.LoadTextureStream(string.Format("images/{0}/{1}", name, item.AssetName));
        }

        public override void Draw(GameTime gameTime)
        {
            int x = item.Position.X*Common.BlockWidth;
            int y = item.Position.Y*Common.BlockHeight;
            SpriteBatch.Draw(texture, new Rectangle(x, y, texture.Width, texture.Height), null, Color.White, 0f,
                Vector2.Zero, SpriteEffects.None, 0.5f);
        }
    }
}
